package com.cust.sky.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
@EnableOpenApi
public class SwaggerConfig {
    @Bean
    public Docket apiDocket() {
        return new Docket(DocumentationType.OAS_30)
                .groupName("管理端接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.cust.sky.controller.admin"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo());
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("系统后台文档")
                .description("本文档描述接口定义")
                .version("1.0.0")
                .build();
    }

    @Bean
    public Docket apiDocket2() {
        return new Docket(DocumentationType.OAS_30)
                .groupName("用户端接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.cust.sky.controller.user"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo2());
    }

    private ApiInfo apiInfo2() {
        return new ApiInfoBuilder()
                .title("系统前台文档")
                .description("本文档描述接口定义")
                .version("1.0.0")
                .build();
    }
}
